{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "0",
   "metadata": {},
   "source": [
    "## 机器学习特征提取(V3版本)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1",
   "metadata": {},
   "outputs": [],
   "source": [
    "from datetime import date\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "import time\n",
    "today_str = date.today().strftime(\"%m_%d\")\n",
    "execfile('yanmu_v3/ml_v3_dp.py')\n",
    "execfile('yanmu_v3/yanmu_util.py')\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2",
   "metadata": {},
   "source": [
    "### 一、获取数据集"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3",
   "metadata": {},
   "source": [
    "#### 1、训练数据集 +特征生成"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4",
   "metadata": {},
   "outputs": [],
   "source": [
    "execfile('yanmu_v3/ml_v3_dp.py')\n",
    "process_train_feature()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "6",
   "metadata": {},
   "source": [
    "#### 2、预测数据集+特征生成"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7",
   "metadata": {},
   "outputs": [],
   "source": [
    "execfile('yanmu_v3/ml_v3_dp.py')\n",
    "file_name = 'predict_v3_07_27.csv'\n",
    "process_predict_feature(file_name)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9",
   "metadata": {},
   "outputs": [],
   "source": [
    "# days_df = pd.read_csv('input/'+str(file_name))[['date', 'code', 'open', 'close', 'high', 'low', 'quote_rate',\n",
    "#        'high_limit', 'turnover', 't_rate', 'xl', 'xl_rate','gn_zt_ratio','hy_zt_ratio']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "10",
   "metadata": {},
   "outputs": [],
   "source": [
    "# days_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "11",
   "metadata": {},
   "outputs": [],
   "source": [
    "days_df = pd.read_csv('input/origin_yanmu_v3_2017_2025.csv',index_col=0).reset_index()[[ 'date', 'code', 'open', 'close', 'high', 'low', 'quote_rate','high_limit', 'turnover', 't_rate', 'xl', 'xl_rate']]\n",
    "days_df = days_df[days_df['date'] <= '2025-04-03']\n",
    "execfile('yanmu_v3/yanmu_turnover.py')\n",
    "xl_yoy_df = mark_col_growth(days_df, 'xl', window=1,is_drop=True)\n",
    "p_col_len(xl_yoy_df)    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "12",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "import seaborn as sns\n",
    "\n",
    "\n",
    "# 执行分析\n",
    "nan_report = analyze_nan_columns(xl_yoy_df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "13",
   "metadata": {},
   "outputs": [],
   "source": [
    "execfile('yanmu_v3/yanmu_turnover.py')\n",
    "xl_yoy_df2 = mark_col_growth2(days_df, 'xl', window=1,is_drop=True)\n",
    "p_col_len(xl_yoy_df2)    \n",
    "nan_report = analyze_nan_columns(xl_yoy_df2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "14",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "15",
   "metadata": {},
   "outputs": [],
   "source": [
    "mark_col_growth2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "16",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
